package com.hzvdvmc.autosale.sale.ui;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.hzvdvmc.autosale.constant.TimeConstant;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by william on 2018/1/15.
 */

public class BaseDialog extends Dialog {
    private Timer timer = new Timer();
    private TimerTask task;

    public BaseDialog(@NonNull Context context) {
        super(context);
    }

    public BaseDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public BaseDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    public void show() {
        super.show();
    }

    @Override
    public void dismiss() {
        super.dismiss();
        if (task != null) {
            task.cancel();
        }
    }

    private void autoDismiss() {
        if (task != null) {
            task.cancel();
        }
        task = new TimerTask() {
            @Override
            public void run() {

            }
        };
        timer.schedule(task, TimeConstant.DIALOG_AUTO_DISMISS);
    }
}
